

$(document).ready(function(){
	var current=1;
	findAccountList(callback,current,"");
});



function findAccountList(callback,current,name){
	
	$.ajax({
		url:urlcore + "/api/account/findAccountList?current=" + current+"&name="+name,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
		callback(data.data.records);
		  $("#pager").pager({
                pagenumber: current,
                pagecount: data.data.pages,
                totalcount: data.data.total,
                buttonClickCallback: PageClick
            });
		}
	
	});
	
	
}



var callback = function (data) {
	$("#thislist").html("");
	    var html="";
	    for (var i = 0; i < data.length; i++) {
	    	var da=data[i];
	    	var userName="--";
	    	if(da.muser.userName!=null){
	    		userName=da.muser.userName;
	    	}
    html += " <tr>"+
            "<td>" + (i + 1) + "</td>\n" +
            "<td>" + userName + "</td>\n" +
            "<td>" + da.muser.phone + "</td>\n" +
            " <td>" + da.duoBi + "</td>\n" +
            " <th>" + da.yaBi + "</th>\n" +
            " <th><a href=\"ret_duobi.html?userId=" + da.muser.id + "\&type=1\" >"+da.unavailableDuobi+"</a></th>\n" +
            " <th><a href=\"ret_duobi.html?userId=" + da.muser.id + "\&type=2\" >"+da.unavailableYabi+"</a></th>\n" +
            " <th><a href=\"ret_duobi.html?userId=" + da.muser.id + "\&type=5\" >"+da.totalMoney+"</a></th>\n" +
            " <th><a href=\"ret_duobi.html?userId=" +da.muser.id + "\&type=3\">"+da.rebateDuobi+"</a></th>\n" +
            " <th><a href=\"ret_duobi.html?userId=" + da.muser.id + "\&type=4\">"+da.rebateYabi+"</a></th>\n" +
            " <th><a href=\"income.html?userId=" + da.muser.id + "\" >"+da.income+"</a></th>" +
            " </tr>";
    }
	 $("#thislist").append(html);
}




PageClick = function (pageclickednumber) {
	var name=$("#name").val();
    findAccountList( callback,pageclickednumber,name);
}

function searchList(){
	var name=$("#name").val();
	findAccountList(callback,1,name)
}
